import { IPSDataEntity } from '../ipsdata-entity';
import { IPSDEServiceAPI } from './ipsdeservice-api';
import { IPSDEServiceAPIField } from './ipsdeservice-apifield';
import { IPSDEServiceAPIMethod } from './ipsdeservice-apimethod';
import { IPSDEServiceAPIRS } from './ipsdeservice-apirs';
import { IPSLanguageRes } from '../../res/ipslanguage-res';
import { IPSSysSFPlugin } from '../../res/ipssys-sfplugin';
import { IPSSysServiceAPI } from '../../service/ipssys-service-api';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDEServiceAPIImpl extends PSModelObjectImpl implements IPSDEServiceAPI {
  get aPIMode(): 1 | 0 | 9 {
    return this.M.aPIMode;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get codeName2(): string {
    return this.M.codeName2;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get extendMode(): 0 | 2 {
    return this.M.extendMode != null ? this.M.extendMode : 0;
  }

  protected lnpslanguageres: IPSLanguageRes | null = null;

  getLNPSLanguageRes(): IPSLanguageRes | null {
    if (this.lnpslanguageres != null) return this.lnpslanguageres;
    const value = this.M.getLNPSLanguageRes;
    if (value == null) {
      return null;
    }
    this.lnpslanguageres = this.getPSModel4('res.IPSLanguageRes', value, 'getLNPSLanguageRes') as IPSLanguageRes;
    return this.lnpslanguageres;
  }

  get lNPSLanguageRes(): IPSLanguageRes | null {
    return this.getLNPSLanguageRes();
  }

  getLNPSLanguageResMust(): IPSLanguageRes {
    const value = this.getLNPSLanguageRes();
    if (value == null) {
      throw new Error('未指定逻辑名称语言资源');
    }
    return value;
  }

  get logicName(): string {
    return this.M.logicName;
  }

  protected majorpsdeserviceapirss: IPSDEServiceAPIRS[] | null = null;

  getMajorPSDEServiceAPIRSs(): IPSDEServiceAPIRS[] | null {
    if (this.majorpsdeserviceapirss == null) {
      const value = this.M.getMajorPSDEServiceAPIRSs;
      if (value == null) {
        return null;
      }
      const arrayNode: any[] = value;
      if (arrayNode.length == 0) {
        return null;
      }
      const list: IPSDEServiceAPIRS[] = [];
      const ipssysserviceapi = this.getParentPSModelObject('service.IPSSysServiceAPI') as IPSSysServiceAPI;
      for (let i = 0; i < arrayNode.length; i++) {
        const item = ipssysserviceapi.findPSDEServiceAPIRS(arrayNode[i]);
        if (item != null) {
          list.push(item);
        }
      }
      this.majorpsdeserviceapirss = list;
    }
    return this.majorpsdeserviceapirss.length == 0 ? null : this.majorpsdeserviceapirss;
  }

  get majorPSDEServiceAPIRSs(): IPSDEServiceAPIRS[] | null {
    return this.getMajorPSDEServiceAPIRSs();
  }

  findMajorPSDEServiceAPIRS(objKey: any): IPSDEServiceAPIRS | null {
    return this.getPSModel5('dataentity.service.IPSDEServiceAPIRS', this.getMajorPSDEServiceAPIRSs(), objKey) as IPSDEServiceAPIRS;
  }

  get memo(): string {
    return this.M.memo;
  }

  protected minorpsdeserviceapirss: IPSDEServiceAPIRS[] | null = null;

  getMinorPSDEServiceAPIRSs(): IPSDEServiceAPIRS[] | null {
    if (this.minorpsdeserviceapirss == null) {
      const value = this.M.getMinorPSDEServiceAPIRSs;
      if (value == null) {
        return null;
      }
      const arrayNode: any[] = value;
      if (arrayNode.length == 0) {
        return null;
      }
      const list: IPSDEServiceAPIRS[] = [];
      const ipssysserviceapi = this.getParentPSModelObject('service.IPSSysServiceAPI') as IPSSysServiceAPI;
      for (let i = 0; i < arrayNode.length; i++) {
        const item = ipssysserviceapi.findPSDEServiceAPIRS(arrayNode[i]);
        if (item != null) {
          list.push(item);
        }
      }
      this.minorpsdeserviceapirss = list;
    }
    return this.minorpsdeserviceapirss.length == 0 ? null : this.minorpsdeserviceapirss;
  }

  get minorPSDEServiceAPIRSs(): IPSDEServiceAPIRS[] | null {
    return this.getMinorPSDEServiceAPIRSs();
  }

  findMinorPSDEServiceAPIRS(objKey: any): IPSDEServiceAPIRS | null {
    return this.getPSModel5('dataentity.service.IPSDEServiceAPIRS', this.getMinorPSDEServiceAPIRSs(), objKey) as IPSDEServiceAPIRS;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdeserviceapifields: IPSDEServiceAPIField[] | null = null;

  getPSDEServiceAPIFields(): IPSDEServiceAPIField[] | null {
    if (this.psdeserviceapifields == null) {
      this.psdeserviceapifields = this.fillChildListModel(this.M.getPSDEServiceAPIFields, 'dataentity.service.IPSDEServiceAPIField') as IPSDEServiceAPIField[];
    }
    return this.psdeserviceapifields;
  }

  get psDEServiceAPIFields(): IPSDEServiceAPIField[] | null {
    return this.getPSDEServiceAPIFields();
  }

  findPSDEServiceAPIField(objKey: any): IPSDEServiceAPIField | null {
    return this.getPSModel5('dataentity.service.IPSDEServiceAPIField', this.getPSDEServiceAPIFields(), objKey) as IPSDEServiceAPIField;
  }

  protected psdeserviceapimethods: IPSDEServiceAPIMethod[] | null = null;

  getPSDEServiceAPIMethods(): IPSDEServiceAPIMethod[] | null {
    if (this.psdeserviceapimethods == null) {
      this.psdeserviceapimethods = this.fillChildListModel(this.M.getPSDEServiceAPIMethods, 'dataentity.service.IPSDEServiceAPIMethod') as IPSDEServiceAPIMethod[];
    }
    return this.psdeserviceapimethods;
  }

  get psDEServiceAPIMethods(): IPSDEServiceAPIMethod[] | null {
    return this.getPSDEServiceAPIMethods();
  }

  findPSDEServiceAPIMethod(objKey: any): IPSDEServiceAPIMethod | null {
    return this.getPSModel5('dataentity.service.IPSDEServiceAPIMethod', this.getPSDEServiceAPIMethods(), objKey) as IPSDEServiceAPIMethod;
  }

  protected psdataentity: IPSDataEntity | null = null;

  getPSDataEntity(): IPSDataEntity | null {
    if (this.psdataentity != null) return this.psdataentity;
    const value = this.M.getPSDataEntity;
    if (value == null) {
      return null;
    }
    this.psdataentity = this.getPSModel4('dataentity.IPSDataEntity', value, 'getPSDataEntity') as IPSDataEntity;
    return this.psdataentity;
  }

  get psDataEntity(): IPSDataEntity | null {
    return this.getPSDataEntity();
  }

  getPSDataEntityMust(): IPSDataEntity {
    const value = this.getPSDataEntity();
    if (value == null) {
      throw new Error('未指定实体对象');
    }
    return value;
  }

  protected pssyssfplugin: IPSSysSFPlugin | null = null;

  getPSSysSFPlugin(): IPSSysSFPlugin | null {
    if (this.pssyssfplugin != null) return this.pssyssfplugin;
    const value = this.M.getPSSysSFPlugin;
    if (value == null) {
      return null;
    }
    this.pssyssfplugin = this.getPSModel4('res.IPSSysSFPlugin', value, 'getPSSysSFPlugin') as IPSSysSFPlugin;
    return this.pssyssfplugin;
  }

  get psSysSFPlugin(): IPSSysSFPlugin | null {
    return this.getPSSysSFPlugin();
  }

  getPSSysSFPluginMust(): IPSSysSFPlugin {
    const value = this.getPSSysSFPlugin();
    if (value == null) {
      throw new Error('未指定后端扩展插件');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get enableDataExport(): boolean {
    return this.M.enableDataExport != null ? this.M.enableDataExport : false;
  }

  get enableDataImport(): boolean {
    return this.M.enableDataImport != null ? this.M.enableDataImport : false;
  }

  get major(): boolean {
    return this.M.major;
  }

  get nested(): boolean {
    return this.M.nested != null ? this.M.nested : false;
  }

  get cls(): string {
    return 'PSDEServiceAPIImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'dataentity.service.IPSDEServiceAPI') return true;
    return super.instanceof(cls);
  }
}
